<?php
	$keys = array_keys($_POST);
	$move_ids = array();
	foreach ($keys as $ids){
		if (strstr($ids, "item")){
			$move_ids[] = $ids;
		}
	}
	$destiny = path_compl($_POST["destination"]);
	$error = 0;
	if (file_exists($destiny) AND trim($destiny) != path_compl($_GET["dir"]) AND !is_restricted($destiny)){
		foreach ($move_ids as $move_me){
			if (!is_restricted($_POST[$move_me])){
				$pathinfo = pathinfo($_POST[$move_me]);
				$compl = path_compl($destiny);
				if (substr($compl, -1) != "/"){
					$compl = $compl."/";
				}
				if (!rename($_POST[$move_me], $compl.$pathinfo["basename"])){
					$error++;
				}
			} else {
				$head->_template_assign("ERROR", (string)$language->errors->value_3);
			}
		}
		if ($error != 0){
			$head->_template_assign("ERROR", sprintf((string)$language->errors->value_17,$error));
		} else {
			$head->_template_assign("STATUS", (string)$language->stati->value_7);
		}
	} else {
		$head->_template_assign("ERROR", (string)$language->errors->value_18);
	}
	
	if (!is_restricted($destiny)){
		$ordner = $destiny;
	} else {
		$ordner = $_GET["dir"];
	}
	if (ALLOW_EASY_MOVE == true){
		build_foldersDB();
	}
	$included = true;
	include("System/Kernel/Includes/index.include.php");
?>